package cn.edu.hbwe.book.servlet.book;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.edu.hbwe.book.dao.impl.BookDaoImpl;
import cn.edu.hbwe.book.entity.Book;

/**
 * Servlet implementation class findBooksByManyCondition
 */
public class findBooksByManyCondition extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
   

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
	
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html;charset=utf-8");
		request.setCharacterEncoding("utf-8");
		String id = request.getParameter("id");
		
		String name = request.getParameter("name");
		String minprice = request.getParameter("minprice");
		String maxprice = request.getParameter("maxprice");
		String category = request.getParameter("category");
		List<Book> books= new ArrayList<Book>();
		BookDaoImpl book=new BookDaoImpl();
		System.out.println(name+";"+id+";"+minprice+";"+maxprice);
		books=book.findBooksbyCondition(id, name,category, minprice, maxprice);
		request.setAttribute("books", books);
		request.getRequestDispatcher("admin/login/book_list.jsp").forward(request, response);
		
		//response.sendRedirect("client/book_list.jsp");//重定向
	}

}
